<?php

namespace backend\models;

use yii\base\Model;
use yii\data\ActiveDataProvider;
use backend\models\School;

/**
 * SchoolSearch represents the model behind the search form of `backend\models\School`.
 */
class SchoolSearch extends School
{
    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['ID', 'SSMZXX'], 'integer'],
            [['DM', 'ZWMC', 'YWMC', 'JC', 'DZ', 'DZDM', 'CS', 'QX', 'SDJYBMDM', 'SDJYBMMC', 'XZQHM', 'ZDCXLX', 'JBZMC', 'BXLB', 'XXLB', 'FSBLX', 'FRZSH', 'FRDBMC', 'FZRXM', 'FZRLXDH', 'JXNY', 'LXDH', 'CZDH', 'ZYDZ', 'YZBM', 'DZXX', 'PGLX', 'SFJLXYW', 'ZGLB', 'XXBB', 'SZDQLB', 'XZXM', 'XZSJH', 'XJLXR', 'XJLXDH', 'ZSZXDH', 'ZSZXYX', 'JJ', 'ZT'], 'safe'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = School::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'ID' => $this->ID,
            'SSMZXX' => $this->SSMZXX,
            'JXNY' => $this->JXNY,
        ]);

        $query->andFilterWhere(['like', 'DM', $this->DM])
            ->andFilterWhere(['like', 'ZWMC', $this->ZWMC])
            ->andFilterWhere(['like', 'YWMC', $this->YWMC])
            ->andFilterWhere(['like', 'JC', $this->JC])
            ->andFilterWhere(['like', 'DZ', $this->DZ])
            ->andFilterWhere(['like', 'DZDM', $this->DZDM])
            ->andFilterWhere(['like', 'CS', $this->CS])
            ->andFilterWhere(['like', 'QX', $this->QX])
            ->andFilterWhere(['like', 'SDJYBMDM', $this->SDJYBMDM])
            ->andFilterWhere(['like', 'SDJYBMMC', $this->SDJYBMMC])
            ->andFilterWhere(['like', 'XZQHM', $this->XZQHM])
            ->andFilterWhere(['like', 'ZDCXLX', $this->ZDCXLX])
            ->andFilterWhere(['like', 'JBZMC', $this->JBZMC])
            ->andFilterWhere(['like', 'BXLB', $this->BXLB])
            ->andFilterWhere(['like', 'XXLB', $this->XXLB])
            ->andFilterWhere(['like', 'FSBLX', $this->FSBLX])
            ->andFilterWhere(['like', 'FRZSH', $this->FRZSH])
            ->andFilterWhere(['like', 'FRDBMC', $this->FRDBMC])
            ->andFilterWhere(['like', 'FZRXM', $this->FZRXM])
            ->andFilterWhere(['like', 'FZRLXDH', $this->FZRLXDH])
            ->andFilterWhere(['like', 'LXDH', $this->LXDH])
            ->andFilterWhere(['like', 'CZDH', $this->CZDH])
            ->andFilterWhere(['like', 'ZYDZ', $this->ZYDZ])
            ->andFilterWhere(['like', 'YZBM', $this->YZBM])
            ->andFilterWhere(['like', 'DZXX', $this->DZXX])
            ->andFilterWhere(['like', 'PGLX', $this->PGLX])
            ->andFilterWhere(['like', 'SFJLXYW', $this->SFJLXYW])
            ->andFilterWhere(['like', 'ZGLB', $this->ZGLB])
            ->andFilterWhere(['like', 'XXBB', $this->XXBB])
            ->andFilterWhere(['like', 'SZDQLB', $this->SZDQLB])
            ->andFilterWhere(['like', 'XZXM', $this->XZXM])
            ->andFilterWhere(['like', 'XZSJH', $this->XZSJH])
            ->andFilterWhere(['like', 'XJLXR', $this->XJLXR])
            ->andFilterWhere(['like', 'XJLXDH', $this->XJLXDH])
            ->andFilterWhere(['like', 'ZSZXDH', $this->ZSZXDH])
            ->andFilterWhere(['like', 'ZSZXYX', $this->ZSZXYX])
            ->andFilterWhere(['like', 'JJ', $this->JJ])
            ->andFilterWhere(['like', 'ZT', $this->ZT]);

        return $dataProvider;
    }
}
